package com.langhang.controller;

import com.langhang.entity.Student;

import com.langhang.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.ArrayList;
import java.util.List;


@Controller
@RequestMapping("/student")
public class StudentController {

	@Autowired
	private StudentService studentService;

	@GetMapping("/list")
	public String list(Model model) {
		List<Student> students = studentService.findAll();
		model.addAttribute("students", students);
		return "student/list";
	}
	@GetMapping("/list1")
	public String list1(Model model,Integer sid) {

		Student students = studentService.findstudentbysid(sid);
		model.addAttribute("student", students);
		return "student/list";
	}


}
